<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    /*  console.log(1);
        for (let i=1;i<10;i++){
        console.log(i);
    }
    */

    //用for循环计算1~100之间的和。  
    let sum = 0;
    for (let i=1;i<=100;i++){
        sum += i;
    }
     console.log(sum);

     console.log('-------------------');

    //用while循环，打印1~100；  
    let i=1;
    while (i<101){
        console.log(i);
        i++;
    }

    console.log('----------------------');

    //用while循环打印1~100的偶数
    let num = 1;
    while (num<=100){
        if(num % 2==0){
            console.log(num);
        }
        num++;
    }

    console.log('-----------');


    // while循环和 do...while循环的区别
    let a = 10;
    while(a<10){
        console.log('执行while循环');
    }//先判断后执行

    let b = 10;
    do{
        console.log('执行do...while 循环');
    }while(b<10)//执行后判断


    console.log('----------');

    //打印4行5列*
    let str = '';
    for (let i = 0;i<4;i++){
        for (let j = 0; j<5;j++){
          str +='*';
        }
        console.log(str+'\n');
    }


    console.log('---------');


    //九九乘法表



</script>
</html>